package lerry.display;

import flash.display.NativeMenuItem;
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.filters.GlowFilter;
import flash.geom.Point;
	
	
	/**
	 * ...
	 * @author lerry
	 */
class CutLine extends Sprite {
	
	public var points:Array<Point>;
	public var length:Int;
	public var line:Shape;
	public var show:Bool;
	public var size:UInt;
	public function new():Void {
		super();
		length = 8;
		show = true;
		size = 1;
		points = new Array<Point>();
		line = new Shape();
		addChild(line);
	}
	
	public function update(x:Float,y:Float):Void {
		
		if (points.length > length||!show) {
			points.shift();
		}
		if (show) {
			points.push(new Point(x, y));
		}
		line.graphics.clear();

		for (i in 0...points.length - 1 ) {
			var k = i > 8?8:i;
			line.graphics.lineStyle(k+size, 0xffffff);
			line.graphics.moveTo(points[i].x, points[i].y);
			line.graphics.lineTo(points[i+1].x, points[i+1].y);
		}
	}
}

